<template>
    <div class="tb-big">
        <el-descriptions  title="账号信息" :column=1>
                <el-descriptions-item label="邮箱">
                    <!-- <el-input v-model="email" style="width:200px;"></el-input> -->
                    
                    <div style="width:200px">{{ this.userInfo.email }}</div>
                    <el-button type="text" @click="dialogemailFormVisible = true">修改邮箱</el-button>

                        <el-dialog class="dialog" title="修改邮箱" :visible.sync="dialogemailFormVisible">
                        <el-form ref="emailForm" :rules="emailRules" :model="emailForm">
                            <el-form-item prop="email2" label="新邮箱" :label-width="formLabelWidth">
                            <el-input v-model="emailForm.email2" autocomplete="off"></el-input>
                            </el-form-item>
                            <el-form-item style="display: flex;" label="原邮箱验证码" :label-width="formLabelWidth">
                                <el-input v-model="emailForm.code" autocomplete="off" style="width:126px ;margin-left: -119px;"></el-input>
                                <el-button>发送验证码</el-button>
                            </el-form-item>
                        </el-form>
                        <div slot="footer" class="dialog-footer">
                            <el-button @click="dialogemailFormVisible = false">取 消</el-button>
                            <el-button type="primary" @click="dialogemailFormVisible = false">确 定</el-button>
                        </div>
                        </el-dialog>


                </el-descriptions-item>
                <el-descriptions-item  label="密码">
                    <el-input v-model="password" disabled show-password style="width:200px;"></el-input>
                    <el-button type="text" @click="dialogPasswordFormVisible = true">修改密码</el-button>

                    <el-dialog title="修改密码" :visible.sync="dialogPasswordFormVisible">
                        <el-form ref="passwordForm" :rules="passwordRules" :model="passwordForm">
                            <el-form-item prop="password2" label="新密码" :label-width="formLabelWidth">
                            <el-input  v-model="passwordForm.password2" autocomplete="off"></el-input>
                            </el-form-item>
                            <el-form-item style="display: flex;" label="邮箱验证码" :label-width="formLabelWidth">
                                <el-input v-model="passwordForm.code" autocomplete="off" style="width:126px ;margin-left: -119px;"></el-input>
                                <el-button>发送验证码</el-button>
                            </el-form-item>
                        </el-form>
                        <div slot="footer" class="dialog-footer">
                            <el-button @click="dialogPasswordFormVisible = false">取 消</el-button>
                            <el-button type="primary" @click="dialogPasswordFormVisible = false">确 定</el-button>
                        </div>
                        </el-dialog>
                </el-descriptions-item>

        </el-descriptions>
        <el-descriptions title="第三方账号"  :column = 1>
            <el-descriptions-item label="qq账号">{{ userInfo.qqNumber == null ? "未关联" :  userInfo.qqNumber }}</el-descriptions-item>
            <el-descriptions-item label="微信账号">{{ userInfo.weChat == null ? "未关联" :  userInfo.weChat }}</el-descriptions-item>
            <el-descriptions-item label="github账号">{{ userInfo.github == null ? "未关联" :  userInfo.github }}</el-descriptions-item>

        </el-descriptions>
    </div>
</template>

<script>
export default {
    name: "",
    components: {},
    props: ["userInfoCopy"],
    data() {

        let checkEmail = (rule, value, callback) => {
            // 判断输入框中是否输入
            if (!value) {
            callback(new Error("邮箱不能为空"));
            }
            //正则表达式进行验证
            if (!/(^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$)/.test(value)) {
            callback(new Error("邮箱格式不正确"));
            }
            callback();
        };

        let checkPass = (rule, value, callback) => {
            if (value === "") {
                callback(new Error("请输入密码"));
            } else if (value.length < 8) {
                callback(new Error("密码至少8位"));
            } else if (!/^\S*$/.test(value)) {
                callback(new Error("不能含有空格"));
            } else if (value.length > 16) {
                callback(new Error("密码不超过16位"));
            } else {
                callback();
            }
        };
        
        
        return {
            userInfo: Object.assign({}, this.userInfoCopy),
            password: '*******************',
            dialogemailFormVisible: false,
            dialogPasswordFormVisible: false,
            emailForm: {
                email2: '',
                code: ''
            },
            passwordForm:{
                password2: '',
                code: ''
            },
            formLabelWidth: '120px',

            emailRules: {
                email2: [{ validator: checkEmail, trigger: "blur" }],
            },
            passwordRules: {
                password2: [{ validator: checkPass, trigger: "blur" }]
            }

        }
        

        

        
    },
    methods:{

    }
};
</script>


<style scoped>


.password >>> .el-input__inner {
  /* width: 90%; */
  background-color: rgb(245, 245, 245);
  border: 1px solid #fff;
}

.password >>> .el-input__inner:hover {
  background-color: rgb(240, 240, 240);
  border: 1px solid rgb(240, 240, 240);
}

.password >>> .el-input__inner:focus {
  background-color: #fff;
  border: 2px solid blue;
}
.tb-big {
    padding: 40px 25px;
    width: 600px;
    height: 450px;
}

.tb-big >>> .el-descriptions-item__label{
    width:120px;
    margin: 10px 0;
}

.tb-big >>> .el-descriptions-item__container{
    align-items: center;
}
.tb-big >>> .el-dialog{
    width: 500px;
}

.el-dialog .el-button{
    margin-left:20px
}

.el-button--text{
    margin-left: 200px;
}
</style>